\(\int x \cos (2 x) \sec (x) \, dx\) [395]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [F]
   Giac [F]
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 8, antiderivative size = 57 \[ \int x \cos (2 x) \sec (x) \, dx=2 i x \arctan \left (e^{i x}\right )+2 \cos (x)-i \operatorname {PolyLog}\left (2,-i e^{i x}\right )+i \operatorname {PolyLog}\left (2,i e^{i x}\right )+2 x \sin (x) \]

[Out]

2*I*x*arctan(exp(I*x))+2*cos(x)-I*polylog(2,-I*exp(I*x))+I*polylog(2,I*exp(I*x))+2*x*sin(x)

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 57, normalized size of antiderivative = 1.00, number of steps used = 12, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.875, Rules used = {4516, 3377, 2718, 4492, 4266, 2317, 2438} \[ \int x \cos (2 x) \sec (x) \, dx=2 i x \arctan \left (e^{i x}\right )-i \operatorname {PolyLog}\left (2,-i e^{i x}\right )+i \operatorname {PolyLog}\left (2,i e^{i x}\right )+2 x \sin (x)+2 \cos (x) \]

[In]

Int[x*Cos[2*x]*Sec[x],x]

[Out]

(2*I)*x*ArcTan[E^(I*x)] + 2*Cos[x] - I*PolyLog[2, (-I)*E^(I*x)] + I*PolyLog[2, I*E^(I*x)] + 2*x*Sin[x]

Rule 2317

Int[Log[(a_) + (b_.)*((F_)^((e_.)*((c_.) + (d_.)*(x_))))^(n_.)], x_Symbol] :> Dist[1/(d*e*n*Log[F]), Subst[Int
[Log[a + b*x]/x, x], x, (F^(e*(c + d*x)))^n], x] /; FreeQ[{F, a, b, c, d, e, n}, x] && GtQ[a, 0]

Rule 2438

Int[Log[(c_.)*((d_) + (e_.)*(x_)^(n_.))]/(x_), x_Symbol] :> Simp[-PolyLog[2, (-c)*e*x^n]/n, x] /; FreeQ[{c, d,
 e, n}, x] && EqQ[c*d, 1]

Rule 2718

Int[sin[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Cos[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 3377

Int[((c_.) + (d_.)*(x_))^(m_.)*sin[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[(-(c + d*x)^m)*(Cos[e + f*x]/f), x]
+ Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Cos[e + f*x], x], x] /; FreeQ[{c, d, e, f}, x] && GtQ[m, 0]

Rule 4266

Int[csc[(e_.) + Pi*(k_.) + (f_.)*(x_)]*((c_.) + (d_.)*(x_))^(m_.), x_Symbol] :> Simp[-2*(c + d*x)^m*(ArcTanh[E
^(I*k*Pi)*E^(I*(e + f*x))]/f), x] + (-Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Log[1 - E^(I*k*Pi)*E^(I*(e + f*x))],
 x], x] + Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Log[1 + E^(I*k*Pi)*E^(I*(e + f*x))], x], x]) /; FreeQ[{c, d, e,
f}, x] && IntegerQ[2*k] && IGtQ[m, 0]

Rule 4492

Int[((c_.) + (d_.)*(x_))^(m_.)*Sin[(a_.) + (b_.)*(x_)]^(n_.)*Tan[(a_.) + (b_.)*(x_)]^(p_.), x_Symbol] :> -Int[
(c + d*x)^m*Sin[a + b*x]^n*Tan[a + b*x]^(p - 2), x] + Int[(c + d*x)^m*Sin[a + b*x]^(n - 2)*Tan[a + b*x]^p, x]
/; FreeQ[{a, b, c, d, m}, x] && IGtQ[n, 0] && IGtQ[p, 0]

Rule 4516

Int[((e_.) + (f_.)*(x_))^(m_.)*(F_)[(a_.) + (b_.)*(x_)]^(p_.)*(G_)[(c_.) + (d_.)*(x_)]^(q_.), x_Symbol] :> Int
[ExpandTrigExpand[(e + f*x)^m*G[c + d*x]^q, F, c + d*x, p, b/d, x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && M
emberQ[{Sin, Cos}, F] && MemberQ[{Sec, Csc}, G] && IGtQ[p, 0] && IGtQ[q, 0] && EqQ[b*c - a*d, 0] && IGtQ[b/d,
1]

Rubi steps \begin{align*} \text {integral}& = \int (x \cos (x)-x \sin (x) \tan (x)) \, dx \\ & = \int x \cos (x) \, dx-\int x \sin (x) \tan (x) \, dx \\ & = x \sin (x)+\int x \cos (x) \, dx-\int x \sec (x) \, dx-\int \sin (x) \, dx \\ & = 2 i x \arctan \left (e^{i x}\right )+\cos (x)+2 x \sin (x)+\int \log \left (1-i e^{i x}\right ) \, dx-\int \log \left (1+i e^{i x}\right ) \, dx-\int \sin (x) \, dx \\ & = 2 i x \arctan \left (e^{i x}\right )+2 \cos (x)+2 x \sin (x)-i \text {Subst}\left (\int \frac {\log (1-i x)}{x} \, dx,x,e^{i x}\right )+i \text {Subst}\left (\int \frac {\log (1+i x)}{x} \, dx,x,e^{i x}\right ) \\ & = 2 i x \arctan \left (e^{i x}\right )+2 \cos (x)-i \operatorname {PolyLog}\left (2,-i e^{i x}\right )+i \operatorname {PolyLog}\left (2,i e^{i x}\right )+2 x \sin (x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.04 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.35 \[ \int x \cos (2 x) \sec (x) \, dx=2 \cos (x)-x \left (\log \left (1-i e^{i x}\right )-\log \left (1+i e^{i x}\right )\right )-i \left (\operatorname {PolyLog}\left (2,-i e^{i x}\right )-\operatorname {PolyLog}\left (2,i e^{i x}\right )\right )+2 x \sin (x) \]

[In]

Integrate[x*Cos[2*x]*Sec[x],x]

[Out]

2*Cos[x] - x*(Log[1 - I*E^(I*x)] - Log[1 + I*E^(I*x)]) - I*(PolyLog[2, (-I)*E^(I*x)] - PolyLog[2, I*E^(I*x)])
+ 2*x*Sin[x]

Maple [A] (verified)

Time = 1.68 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.16

method result size
default \(x \ln \left (1+i {\mathrm e}^{i x}\right )-x \ln \left (1-i {\mathrm e}^{i x}\right )-i \operatorname {dilog}\left (1+i {\mathrm e}^{i x}\right )+i \operatorname {dilog}\left (1-i {\mathrm e}^{i x}\right )+2 \cos \left (x \right )+2 x \sin \left (x \right )\) \(66\)
risch \(-i \left (x +i\right ) {\mathrm e}^{i x}+i \left (x -i\right ) {\mathrm e}^{-i x}+x \ln \left (1+i {\mathrm e}^{i x}\right )-x \ln \left (1-i {\mathrm e}^{i x}\right )-i \operatorname {dilog}\left (1+i {\mathrm e}^{i x}\right )+i \operatorname {dilog}\left (1-i {\mathrm e}^{i x}\right )\) \(81\)

[In]

int(x*cos(2*x)*sec(x),x,method=_RETURNVERBOSE)

[Out]

x*ln(1+I*exp(I*x))-x*ln(1-I*exp(I*x))-I*dilog(1+I*exp(I*x))+I*dilog(1-I*exp(I*x))+2*cos(x)+2*x*sin(x)

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 106 vs. \(2 (36) = 72\).

Time = 0.26 (sec) , antiderivative size = 106, normalized size of antiderivative = 1.86 \[ \int x \cos (2 x) \sec (x) \, dx=-\frac {1}{2} \, x \log \left (i \, \cos \left (x\right ) + \sin \left (x\right ) + 1\right ) + \frac {1}{2} \, x \log \left (i \, \cos \left (x\right ) - \sin \left (x\right ) + 1\right ) - \frac {1}{2} \, x \log \left (-i \, \cos \left (x\right ) + \sin \left (x\right ) + 1\right ) + \frac {1}{2} \, x \log \left (-i \, \cos \left (x\right ) - \sin \left (x\right ) + 1\right ) + 2 \, x \sin \left (x\right ) + 2 \, \cos \left (x\right ) + \frac {1}{2} i \, {\rm Li}_2\left (i \, \cos \left (x\right ) + \sin \left (x\right )\right ) + \frac {1}{2} i \, {\rm Li}_2\left (i \, \cos \left (x\right ) - \sin \left (x\right )\right ) - \frac {1}{2} i \, {\rm Li}_2\left (-i \, \cos \left (x\right ) + \sin \left (x\right )\right ) - \frac {1}{2} i \, {\rm Li}_2\left (-i \, \cos \left (x\right ) - \sin \left (x\right )\right ) \]

[In]

integrate(x*cos(2*x)*sec(x),x, algorithm="fricas")

[Out]

-1/2*x*log(I*cos(x) + sin(x) + 1) + 1/2*x*log(I*cos(x) - sin(x) + 1) - 1/2*x*log(-I*cos(x) + sin(x) + 1) + 1/2
*x*log(-I*cos(x) - sin(x) + 1) + 2*x*sin(x) + 2*cos(x) + 1/2*I*dilog(I*cos(x) + sin(x)) + 1/2*I*dilog(I*cos(x)
 - sin(x)) - 1/2*I*dilog(-I*cos(x) + sin(x)) - 1/2*I*dilog(-I*cos(x) - sin(x))

Sympy [F]

\[ \int x \cos (2 x) \sec (x) \, dx=\int x \cos {\left (2 x \right )} \sec {\left (x \right )}\, dx \]

[In]

integrate(x*cos(2*x)*sec(x),x)

[Out]

Integral(x*cos(2*x)*sec(x), x)

Maxima [F]

\[ \int x \cos (2 x) \sec (x) \, dx=\int { x \cos \left (2 \, x\right ) \sec \left (x\right ) \,d x } \]

[In]

integrate(x*cos(2*x)*sec(x),x, algorithm="maxima")

[Out]

2*x*sin(x) + 2*cos(x) - 2*integrate((x*cos(2*x)*cos(x) + x*sin(2*x)*sin(x) + x*cos(x))/(cos(2*x)^2 + sin(2*x)^
2 + 2*cos(2*x) + 1), x)

Giac [F]

\[ \int x \cos (2 x) \sec (x) \, dx=\int { x \cos \left (2 \, x\right ) \sec \left (x\right ) \,d x } \]

[In]

integrate(x*cos(2*x)*sec(x),x, algorithm="giac")

[Out]

integrate(x*cos(2*x)*sec(x), x)

Mupad [B] (verification not implemented)

Time = 26.55 (sec) , antiderivative size = 46, normalized size of antiderivative = 0.81 \[ \int x \cos (2 x) \sec (x) \, dx=2\,\cos \left (x\right )+2\,x\,\sin \left (x\right )-\mathrm {polylog}\left (2,-{\mathrm {e}}^{x\,1{}\mathrm {i}}\,1{}\mathrm {i}\right )\,1{}\mathrm {i}+\mathrm {polylog}\left (2,{\mathrm {e}}^{x\,1{}\mathrm {i}}\,1{}\mathrm {i}\right )\,1{}\mathrm {i}+x\,\mathrm {atan}\left ({\mathrm {e}}^{x\,1{}\mathrm {i}}\right )\,2{}\mathrm {i} \]

[In]

int((x*cos(2*x))/cos(x),x)

[Out]

2*cos(x) - polylog(2, -exp(x*1i)*1i)*1i + polylog(2, exp(x*1i)*1i)*1i + x*atan(exp(x*1i))*2i + 2*x*sin(x)